<script>
const ACC = {
    template: '<h2>myComponent a</h2>',
    beforeUnmount() {
        setTimeout(() => {
            console.log('----------componenta:beforeUnmount------------');
        }, 1000);
    }, unmounted() {
        setTimeout(() => {
            console.log('----------componenta:unmounted------------');
        }, 6000);
    }
}
const BCC = {
    template: '<h2>myComponent b</h2>',
    beforeUnmount() {
        setTimeout(() => {
            console.log('----------componentb:beforeUnmount------------');
        }, 1000);
    }, unmounted() {
        setTimeout(() => {
            console.log('----------componentb:unmounted------------');
        }, 6000);
    }
}
export default {
    data() {
        return {
            flag: 1
        }
    },
    components: {
        acc: ACC,
    },
}
</script>

<template>
    <div>{{ flag }}</div>
    <input type="button" value="点击" @click="flag = 2">
    <acc v-if="flag == 1">a</acc>
</template>